using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using ShevaEngine2GUI;
using ShevaEngine.Core;
using ShevaEngine2GUI.Controls;
using ShevaEngine2GUI.Styles;
using ShevaEngine.Core.Modules;
using ShevaEngine2GUI.Styles.Default;

namespace GUITest
{
    /// <summary>
    /// This is the main type for your game
    /// </summary>
    public class GuiTest : IShevaEngineGamePart
    {
        GuiManager GuiManager;

        /// <summary>
        /// Cnstructor.
        /// </summary>
        public GuiTest()
        {
            this.GuiManager = new GuiManager(
                new Vector2(
                    ShevaEngine.Core.ShevaEngine.Instance.GraphicsDevice.Viewport.Width,
                    ShevaEngine.Core.ShevaEngine.Instance.GraphicsDevice.Viewport.Height));

            Layer newLayer = this.GuiManager.CreateNewLayer();
            newLayer.BackColor = Color.Black;



            for (int i = 0; i < 10; i++)
            {
                Button newButton = new Button();
                newButton.Style = DefaultButtonStyle.Instance;
                newButton.BackColor = Color.White;
                newButton.Text = "Test";
                newButton.Font = FontManager.Instance["Arial12"];
                newButton.ForeColor = Color.Red;
                newButton.LocationSize = new Rectangle(100, 100 + 40 * i, 256, 32);
                newLayer.Controls.Add(newButton);
            }

            for (int i = 0; i < 10; i++)
            {
                Button newButton = new Button();
                newButton.Style = DefaultButtonStyle.Instance;
                newButton.BackColor = Color.White;
                newButton.Text = "Test";
                newButton.Font = FontManager.Instance["Arial12"];
                newButton.ForeColor = Color.Red;
                newButton.LocationSize = new Rectangle(500, 100 + 40 * i, 256, 32);
                newLayer.Controls.Add(newButton);
            }

            this.GuiManager.MouseLayer = newLayer;
            this.GuiManager.Layers.Add(newLayer);
        }

        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        public void Update(GameTime gameTime)
        {
            this.GuiManager.Update(gameTime);
        }

        /// <summary>
        /// This is called when the game should draw itself.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        public void Draw()
        {
            this.GuiManager.Draw();
        }

        public void Activate()
        {
            
        }

        public void Deactivate()
        {
            
        }        
    }
}
